<template>
  <div class="home">
    <div class="beijingtu">
      <div class="beijingtu2">
        <div class="beijingtu3">
          <el-form class="center" ref="form" :model="form">
              <p class="center_title">登录</p>
              <div class="pub_box">
                  <el-form-item for="yx" class="public_fm" label="邮箱：" prop="email" >
                      <el-input id="yx" class="public_ipt" placeholder="请输入邮箱" v-model="form.email"></el-input>
                  </el-form-item>
              </div>
              <div class="pub_box">
                  <el-form-item for="mm" class="public_fm" label="密码：" prop="password">
                      <el-input id="mm" class="public_ipt" placeholder="请输入密码" v-model="form.password"></el-input>
                  </el-form-item>
              </div>
              <el-form-item>
                <el-button id="sign" type="primary" @click="onSubmit()">登录</el-button>
              </el-form-item>
              <p class="bottom">——————考试题库管理系统——————</p>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>


<script>
  import login from '../Mockjs/Login/login'
  import axios from 'axios'
  export default {
    data() {
      return {
        loadingbut:false,
        form: {
            emall: '',
            password: '',
        },
        
          
      }
    },
    methods: {
      onSubmit() {
        login.login()
        this.loadingbut=true,
        axios.post(`/api/login`,this.form).then(req=>{
          this.loadingbut=false;
          if (req.data.code === 1) {
            localStorage.setItem('token',req.data.token)
            this.$router.push("/");
            setTimeout(()=>{
              location.reload();
              localStorage.setItem('email',req.data.email)
            },100)
          } else {
            this.$message.error("请输入正确的邮箱或密码");
          }
        })
        
      }
    }
  }
</script>

<style scoped>
  .beijingtu{
    width: 100%;
    background: url(./004.png) no-repeat 50%;
    min-height: 100%;
    position: relative;
    height: 100%;
  }
  .home{
    height: 100%;
  }
  .div1{
    height: 100%;
    width: 100%;
  }
  .center {
      width: 35.5%;
      height: 430px;
      max-width: 40%;
      background-color: white;
      
      border-radius:15px;
      margin-left: auto;
      margin-right: auto;
      border: solid;
      opacity: 0.8;
  }
  .center_title {
      font-size: 25px;
      padding-top: 30px;
      text-align: center;
  }
  .pub_box {
      width: 100%;
      margin: auto;
      margin-top: 30px;
  }
  .public_fm {
      padding-left: 8%;
  }
  .public_ipt {
      width: 75%;
      float: left;
  }
  #sign {
      margin-top: 20px;
      width: 89%;
      margin-left: 5.5%;
  }
  .bottom {
      font-size: 16px; 
      color: darkgray;
      text-align: center;
      padding-top: 15px;
  }
  .public_ipt {
      width: 89%;
  }
  .beijingtu2{
      display: table;
      width: 100%;
      height: 100%;
  }
  .beijingtu3{
      display: table-cell;
      vertical-align: middle;
  }
</style>
